﻿@model IEnumerable<vw08_equest.Areas.Administrator.Models.Question>

<style type="text/css">
    .alert
    {
    	display:none;
    }
</style>

<script type="text/javascript">
    $(document).ready(function () {
        ShowArlert();
    });

    function ShowArlert() {
        var Error = '@ViewBag.Error';
        if (Error != '')
            $(".alert-error").show();
        var Success = '@ViewBag.Success';
        if (Success != '')
            $(".alert-success").show();
        var Warning = '@ViewBag.Warning';
        if (Warning != '')
            $(".alert-info").show();
    }

    function Delete(id) {
        var ok = confirm('Xác nhận xóa câu hỏi?');
        if (ok == true) {
            var input = $("<input>").attr("type", "hidden").attr("name", "id").val(id);
            $('#DeleteForm').append($(input));
            $('#DeleteForm').submit();
        }
        else {
            return;
        }
    }
</script>

<div class="page-header">
    <div class="icon">
        <span class="ico-layout-7"></span>
    </div>
    <h1>
        Danh sách câu hỏi <small>VWSOL METRO STYLE ADMIN PANEL</small></h1>
</div>
<div class="row-fluid">            
    <div class="span12">
        <div class="block">
            <div class="alert alert-error">            
                <strong>@ViewBag.Error</strong>
            </div>
            <div class="alert alert-success">            
                <strong>@ViewBag.Success</strong>
            </div>            
            <div class="alert alert-info">            
                <strong>@ViewBag.Warning</strong>
            </div>
            <div class="head blue">
                <div class="icon">
                    <span class="ico-pen-2"></span>
                </div>
                <h2>
                    Câu hỏi đã khai báo</h2>
                <ul class="buttons">
                    <li><a href="javascript:void(0)">
                        <div class="icon">
                            <span class="ico-info"></span>
                        </div>
                    </a></li>
                </ul>
            </div>
            <div class="data-fluid">
                <table class="table fpTable lcnp" cellpadding="0" cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th width="20px">
                                #
                            </th>
                            <th>
                                Câu hỏi
                            </th>
                            <th width="100">
                                Độ khó
                            </th>
                            <th width="150">
                                Ngày tạo
                            </th>
                            <th width="80" class="TAC">
                                Actions
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @{int i = 1;}
                        @foreach (var item in Model)
                        {
                            <tr>
                                <td>
                                    @i
                                </td>
                                <td>
                                    <a href="javascript:void(0)">@item.Question1</a>
                                </td>
                                <td>
                                    @{
                                        if(item.QuestionLevel == 1)
                                        {
                                            <text>Dễ</text>
                                        }
                                        else if (item.QuestionLevel == 2)
                                        {
                                            <text>Trung bình</text>
                                        }
                                        else if (item.QuestionLevel == 3)
                                        {
                                            <text>Khó</text>
                                        }
                                        else
                                        {
                                            <text>N/A</text>
                                        }
                                     }
                                </td>
                                <td>
                                    @item.CreatedDate.ToString("dd-MM-yyyy hh:mm")
                                </td>
                                <td>
                                    <a href="@Url.Content("~/Administrator/AdminQuestion/EditQuestion/" + item.QuestionID)" class="button green">
                                        <div class="icon">
                                            <span class="ico-pencil"></span>
                                        </div>
                                    </a>                                
                                    <a href="javascript:void(0)" class="button red" onclick="Delete('@item.QuestionID');">
                                        <div class="icon">
                                            <span class="ico-remove"></span>
                                        </div>
                                    </a>
                                </td>
                            </tr>
                                        i++;
                        }   
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<div style="display:none">
    @using (Html.BeginForm("DeleteQuestion", "AdminQuestion", FormMethod.Post, new { id = "DeleteForm", enctype = "multipart/form-data" }))
    {
    }
</div>